package br.edu.ufcg.greengrid.workload;

public class Job implements Comparable<Job> {

    private int jobId;
    private int submitTime;
    private int runTime;
    private int nProc;
	private String site;

    public Job(int jobId, int submitTime, int runTime, int nProc, String site) {
        this.jobId = jobId;
        this.submitTime = submitTime;
        this.runTime = runTime;
        this.nProc = nProc;
        this.site = site;
    }

    public int getJobId() {
        return jobId;
    }

    public int getSubmitTime() {
        return submitTime;
    }

    public int getRunTime() {
        return runTime;
    }

    public int getNProc() {
        return nProc;
    }
    
	public String getOrigSite() {
		return this.site;
	}

    @Override
    public int compareTo(Job o) {
        int diffTime = this.submitTime - o.submitTime;
        if (diffTime == 0) {
            if (jobId > o.jobId) {
                return 2;
            } else if (jobId == o.jobId){
            	return this.hashCode() == o.hashCode() ? 0 : (this.hashCode() > o.hashCode() ? 1 : -1);
            } else {
                return -2;
            }
        } else if (diffTime > 0) {
            return 5;
        } else {
            return -5;
        }
    }
}
